using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace MTRC.ODMS.Web.SOM.Popup
{
    /// <summary>
    /// author:SQB
    /// </summary>
    public partial class PopupRelativeEvent : BasePage_SOM
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                // add by dylan 20151030 for u275.1 
                this.grvData.PageSize = this.GridViewPageDefaultSize();
                SetLanguage();
                this.btnClose.Attributes.Add("onclick", "javascript:window.close();return false;");
            }
        }

        private void SetLanguage()
        {
            if (this.LangCode == "1")
            {
                this.btnSearch.Attributes.Add("onclick", "return Search_Click('" + this.GetLabel("SOM_Eventwithin") + " " + this.GetMessage("SOM_NotIsEmpty") + "');");
            }
            else
            {
                this.btnSearch.Attributes.Add("onclick", "return Search_Click('" + this.GetLabel("SOM_Eventwithin") + this.GetMessage("SOM_NotIsEmpty") + "');");
            }

            this.lblRelative.Text = this.GetLabel("SOM_Eventwithin", true);
            this.lblDays.Text = this.GetLabel("SOM_Days");
            this.btnSearch.Text = this.GetLabel("COM_Search");
            this.btnClose.Text = this.GetLabel("COM_Close");
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            BindData();
        }

        private void BindData()
        {
            DataTable dt = MTRC.ODMS.DAL.SOM.Event.StationEventGeneralEventDa.GetRelativeEvent(this.LangCode,int.Parse(this.txtDays.Text.Trim()));
            this.grvData.DataSource = dt.DefaultView;
            this.grvData.DataBind();
        }

        protected void grvData_NeedDataBind()
        {
            BindData();
        }

        protected void grvData_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Attributes.Add("onmouseover", "this.oldcolor=this.style.backgroundColor;this.style.backgroundColor='#eaffd9';");
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=this.oldcolor");
                e.Row.Attributes.Add("onclick", "RowClick('" 
                                + this.grvData.DataKeys[e.Row.RowIndex]["StationEventID"].ToString() + "','"
                                + this.Server.HtmlDecode(e.Row.Cells[0].Text.Trim()) + "')");
                //+ this.Server.HtmlDecode(e.Row.Cells[2].Text.Trim().Replace("\r\n","\\n")) + "')"); //Modify by zengshunbo 2009-01-06 issue 0920
            }
        }
    }
}
